// example/order_list/order_list.js
var app = getApp()
import * as Api from '../../utils/api.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
 hasGoneAway: true,
    initDefalut: false,
    addEdit: false,
    pagetype: '',
    cartId: '',
    info: [],
    dpFlag:false,
    defaultAddress: [],
    haveAdd: false,
    productList: [],
    skuid: '',
    orderNum: 0,
    orderPrice: 0,
    remark: '',
    remarkLen: 0,
    prepareId: '',
    addressModel: false,
    addresslist: [],
    region: ['北京市', '北京市', '东城区'],//下标
    isdefault: false,
    paidAccount: false,  // 是否需要挂单
    pagetype: '', //页面类型  edit  add
    idList: [],
    // 信息
    contactname: '',
    contactmobile: '',
    address: '',
    addressId: ''
  },
  save() {


    if (this.data.pagetype === 'edit') {
      console.log('修改')
      let self = this
      let url = app.globalData.baseUrl1 + '/address/update';
      let data = {
        token: app.globalData.token,
        userId: app.globalData.userId,
        addressId: this.data.addressId,
        provinceId: this.data.idList[0],
        cityId: this.data.idList[1],
        countryId: this.data.idList[2],
        address: this.data.address,
        contactName: this.data.contactname,
        contactMobile: this.data.contactmobile,
        isDefault: this.data.isdefault
      }
      let callBack = (res) => {

        if (res == null) {

          console.log("网络请求错误！");
          return;
        }
        if (res.data.status != 200) {
          console.log("请求数据错误");
          return;
        }



        self.getaddressList()
        self.changeAddEdit()

      }
      Api.reqFormPost(url, data, callBack)







    } else {


      console.log('新增')


      let url = app.globalData.baseUrl1 + '/address/add';

      let data = {
        token: app.globalData.token,
        userId: app.globalData.userId,
        provinceId: this.data.idList[0],
        cityId: this.data.idList[1],
        countryId: this.data.idList[2],
        address: this.data.address,
        contactName: this.data.contactname,
        contactMobile: this.data.contactmobile,
        isDefault: this.data.isdefault
      }
      let self = this

      let callBack = (res) => {

        console.log(res)
        if (res == null) {

          console.log("网络请求错误！");
          return;
        }

        if (res.data.status != 200) {
          console.log("请求数据错误");
          return;
        }


        self.getaddressList()
        self.changeAddEdit()
      }
      Api.reqFormPost(url, data, callBack)
    }

  },

  StringToId() {

    if (this.data.contactname === '' || this.data.contactmobile === '' || this.data.address === '') {
      return
    }

    var re = /^1[3|4|5|7|8|6][0-9]\d{4,8}$/;
    var zuoji = /^0\d{2,3}[- ][1-9]\d{6,7}$/;

    if (!re.test(this.data.contactmobile)) {
      if (!zuoji.test(this.data.contactmobile)) {

        wx.showModal({
          title: '',
          content: '联系电话格式错误',
          showCancel: false,
          cancelText: '',
          cancelColor: '',
          confirmText: '知道了',
          confirmColor: '',
          success: function (res) { },
          fail: function (res) { },
          complete: function (res) { },
        })
        return;
      }

    } 



    let self = this
    let url = app.globalData.baseUrl1 + '/address/querycityid'
    let data = {
      provinceName: self.data.region[0],
      cityName: self.data.region[1],
      countryName: self.data.region[2]
    }

    let callBack = (res) => {
      if (res == null) {
        console.log("网络请求错误！");
        return;
      }
      if (res.data.status != 200) {
        console.log("请求数据错误");
        return;
      }
      if (res.data.status === 200) {
        console.log(res.data)

        self.data.idList[0] = res.data.data.province.id
        self.data.idList[1] = res.data.data.city.id
        self.data.idList[2] = res.data.data.country.id
        self.setData({
          idList: self.data.idList
        })
        self.save()
      }

    }
    Api.reqFormPost(url, data, callBack)
  },
  handleInpue(e) {
    switch (e.currentTarget.dataset.name) {
      case 'contactname':
        this.setData({
          contactname: e.detail.value
        })
        break;
      case 'contactmobile':
        this.setData({
          contactmobile: e.detail.value
        })
        break;
      case 'address':
        this.setData({
          address: e.detail.value
        })
        break;
    }
  },
  picChange(e) {

    console.log(e.detail.value)

    this.setData({
      region: e.detail.value,
    })

  },
  doDefault(e) {
    if (this.data.initDefalut) {
      return
    }
    this.setData({
      isdefault: !this.data.isdefault
    })
  },
  changeRemark(e) {

    this.setData({
      remark: e.detail.value,
      remarkLen: e.detail.cursor
    })
  },
  catl() {
    return
  },
  changeAddEdit(e) {

    this.setData({
      addEdit: !this.data.addEdit,
      initDefalut: false
    })
    if (e) {

      if (e.currentTarget.dataset.type == 'edit') {
        let region = [
          e.currentTarget.dataset.item.province,
          e.currentTarget.dataset.item.city,
          e.currentTarget.dataset.item.country
        ]
        this.setData({
          pagetype: e.currentTarget.dataset.type,
          contactname: e.currentTarget.dataset.item.contactname,
          contactmobile: e.currentTarget.dataset.item.contactmobile,
          address: e.currentTarget.dataset.item.address,
          isdefault: e.currentTarget.dataset.item.isdefault,
          initDefalut: e.currentTarget.dataset.item.isdefault,
          region: region,
          addressId: e.currentTarget.dataset.item.addressId
        })
      } else {
        this.setData({
          contactname: '',
          contactmobile: '',
          address: '',
          isdefault: false,
          region: ['北京市', '北京市', '东城区'],
          addressId: ''
        })
      }

      this.setData({
        pagetype: e.currentTarget.dataset.type
      })
    }




  },
  getaddressList() {
    console.log('获取地址')

    let self = this

    let url = app.globalData.baseUrl1 + '/address/list';

    let data = {
      token: app.globalData.token,
      userId: app.globalData.userId
    }
    let callBack = (res) => {

      if (res == null) {

        console.log("网络请求错误！");
        return;
      }

      if (res.data.status != 200) {
        console.log("请求数据错误" + url);
        return;
      }
      if (res.data.status === 200) {
        self.setData({
          addresslist: res.data.data.addresslist
        })
      }
    }
    Api.reqFormPost(url, data, callBack)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (app.globalData.merchant === null) {
      app.doLogin(this.onLoad, this.onShow, options);
      return
    }
    let self = this
    wx.showLoading({
      mask: true,
      title: '加载中'
    })
    if (options.pagetype === 'carts') {
      this.setData({
        cartId: options.id
      })
      this.getCarList();
      this.setData({
        pagetype: options.pagetype,
      })
      wx.request({
        method: 'post',
        url: app.globalData.baseUrl1 + '/order/createprepare',
        data: {
          token: app.globalData.token,
          userId: app.globalData.userId,
          cartIdList: self.data.cartId
        },
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        success: function (res) {
          console.log(res.data.data)
          self.setData({
            prepareId: res.data.data.prepareId
          })
          self.getAddress();




          console.log('生成预支付订单' + self.data.prepareId)
          self.getPreOrder()
        }
      })


    } else if (options.pagetype === 'shop') {

      let url = app.globalData.baseUrl1 + '/goods/front/simpledetail'
      let data = {
        token: app.globalData.token,
        userId: app.globalData.userId,
        goodsId: options.goodsid,
      }
    

      let callBack = (res) => {
       
        if (res == null) {

          console.log("网络请求错误！");
          return;
        }

        if (res.data.status != 200) {
          console.log("请求数据错误");
          return;
        }
        if (res.data.status === 200) {
          console.log(res)

          let productList = [];
          productList[0] = res.data.data
          if (productList[0].imageList.split(',').length > 0) {
            productList[0].goodsIcon = productList[0].imageList.split(',')[0]
          }
          productList[0].goodsName = productList[0].goodsName
          productList[0].price = productList[0].memberPrice
          productList[0].num = options.num

          self.setData({
            productList: productList,
            skuid: options.skuid,
            orderNum: options.num,
            orderPrice: (productList[0].memberPrice * options.num).toFixed(2),
          })
          self.setData({
            pagetype: options.pagetype,
          })

          let url = app.globalData.baseUrl1 + '/order/directpay'
          let data = {
            token: app.globalData.token,
            userId: app.globalData.userId,
            goodsId: this.data.productList[0].goodsId,
            skuId: this.data.skuid,
            num: this.data.productList[0].num
          }
          let callBack = (res1) => {
            wx.hideLoading()   
            if (res1 == null) {

              console.log("网络请求错误1！");
              return;
            }

            if (res1.data.status != 200) {
              console.log("请求数据错误1");
              return;
            }

            if (res1.data.status == 200) {
              console.log(res1.data.data)
              self.setData({
                prepareId: res1.data.data.prepareId
              })
              self.getAddress();

              console.log('生成预支付订单' + self.data.prepareId)

            }
          }
          Api.reqFormPost(url, data, callBack)


        }
      }

      Api.reqFormPost(url, data, callBack)

    }else{
      console.log('多品')
      this.setData({
        dpFlag:true
      })
      let url = app.globalData.baseUrl1 + '/order/directpay/new'
      let attr = wx.getStorageSync('goodsVo') ? wx.getStorageSync('goodsVo') :''
      console.log(attr)
      this.getAddress()
      let data = {
        model: JSON.parse(attr),
        token: app.globalData.token,
        userId: app.globalData.userId,
        contentType: true
      }
      let callBack = (res) => {
       wx.hideLoading() 
        if (res == null) {
          console.log("网络请求错误！");
          return;
        }
        if (res.data.status != 200) {
          console.log("请求数据错误");
          return;
        }
        if (res.data.status == 200) {
            console.log(res)
            wx.removeStorage({
              key: 'goodsVo',
              success: function(res) {},
            })
            self.setData({
              orderNum: res.data.data.goodsNum,
              orderPrice: res.data.data.totalPrice,
              productList: res.data.data.goodslit,
              prepareId: res.data.data.prepareId
            })
        }
      }
      Api.reqFormPost(url, data, callBack)
    }

  },

  getCarList: function () {
    let self = this
    wx.request({
      method: 'post',
      url: app.globalData.baseUrl1 + '/shopcart/query', //仅为示例，并非真实的接口地址
      data: {
        token: app.globalData.token,
        userId: app.globalData.userId,
        goodsId: this.data.goodsId
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 默认值
      },
      success: function (res) {
        console.log(1, res)
        let productList = []

        for (let i = 0; i < res.data.data[0].cartlist.length; i++) {
          for (let j = 0; j < self.data.cartId.split(',').length; j++) {
            if (res.data.data[0].cartlist[i].cartId === self.data.cartId.split(',')[j]) {
              productList.push(res.data.data[0].cartlist[i])
            }
          }
        }
        console.log(333, productList)
        self.setData({
          orderNum: res.data.data[0].goodsNum,
          orderPrice: res.data.data[0].totalPrice,
          info: res.data.data[0].cartlist,
          productList: productList
        })
      }
    })
  },
  getAddress() {
    let self = this
    wx.request({
      method: 'post',
      url: app.globalData.baseUrl1 + '/address/defaultaddress',
      data: {
        token: app.globalData.token,
        userId: app.globalData.userId
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 默认值
      },
      success: function (res) {
        console.log(22, res.data.data)
        if (res.data.data.address) {
          console.log('有地址')
          self.setData({
            defaultAddress: res.data.data,
            haveAdd: true
          })
        }
      }
    })
  },



  setAddressPreperId(e) {

    console.log('修改订单提交的地址')
    let self = this

    let url = app.globalData.baseUrl1 + '/order/updateAddressId/new' 

    let data = {
      token: app.globalData.token,
      userId: app.globalData.userId,
      prepareId: this.data.prepareId,
      addressId: e.currentTarget.dataset.addid
    }
    let callBack = (res) => {

      if (res == null) {
        console.log("网络请求错误！");
        return;
      }

      if (res.data.status != 200) {
        console.log("请求数据错误" + url);
        return;
      }
      if (res.data.status === 200) {

        self.setData({
          addressModel: !self.data.addressModel
        })
        console.log(res)
        if (res.data.data) {
          self.setData({
            defaultAddress: res.data.data,
            haveAdd: true
          })
        }
        //self.getPreOrder()
      }
    }
    Api.reqFormPost(url, data, callBack)


  },
  selectAddress() {
    // wx.navigateTo({
    //   url: '../select_address/select_address?prepareId=' + this.data.prepareId + '&addid=' + this.data.defaultAddress.addressid
    // })
    this.setData({
      addressModel: !this.data.addressModel
    })
    this.getaddressList()
  },
  // 挂单 
  cancellFn() {

    return
    wx.redirectTo({
      url: '../cancell/cancell'
    })
  },

  pay(e) {
    console.log(e)
    console.log(e.currentTarget.dataset.type)
    if (app.globalData.merchant.memberAudit && !app.globalData.loginName){
        wx.navigateTo({
        url: '/pages/core/login/login',
      })
      return
    }
    if (this.data.remarkLen > 50) {

      return
    }
    if (!this.data.haveAdd) {
      console.log('请选择一个地址')

      wx.showModal({
        title: '提示',
        content: '请选择一个地址',
        showCancel: false,
        confirmText: '知道了',
        success: function (res) {

          if (res.confirm) {
            console.log('用户点击确定')
          } else if (res.cancel) {
            console.log('用户点击取消')
          }
        }
      })
      return
    }
    let self = this
    wx.showLoading({
      mask: true,
      title: '加载中'
    })
    // 多品提交订单
    if (this.data.dpFlag){
      wx.request({
        method: 'post',
        url: app.globalData.baseUrl1 + '/order/submitorder/new', 
        data: {
          token: app.globalData.token,
          userId: app.globalData.userId,
          prepareId: this.data.prepareId,
          remark: self.data.remark,
          type: e.currentTarget.dataset.type ? 'onAccount' : ''
        },
        header: {
          'content-type': 'application/x-www-form-urlencoded' // 默认值
        },
        success: function (res1) {

          console.log(1, res1)
          if (e.currentTarget.dataset.type) {
            if(res1.data.status == 200){
                wx.redirectTo({
                  url: '../cancell/cancell?total=' + res1.data.data.totalPrice
                })
                return
            }else{
              wx.showToast({
                icon:'none',
                title: res1.data.message
              })
            }
            
          }
          wx.request({
            method: 'post',
            url: app.globalData.baseUrl1 + '/wechat/pay/miniapp',
            data: {
              token: app.globalData.token,
              userId: app.globalData.userId,
              openId: app.globalData.openid,
              body: app.globalData.merchant.merchantName,
              outTradeNo: res1.data.data.payId,
              totalFee: res1.data.data.totalPrice
              // self.data.orderPrice * 100
            },
            header: {
              'content-type': 'application/x-www-form-urlencoded' // 默认值
            },
            success: function (res2) {
              console.log('购物车支付', res2)
              wx.hideLoading()
              if (res2 == null) {
                wx.hideLoading();  
                console.log("网络请求错误3！");
                return;
              }

              if (res2.data.status != 200) {
                wx.showModal({
                  title: '',
                  content: res2.data.data.return_msg,
                  showCancel: false,
                  cancelText: '',
                  cancelColor: '',
                  confirmText: '知道了',
                  confirmColor: '',
                  success: function (res) {



                    wx.navigateBack({
                      delta: 1,
                    })


                  },
                  fail: function (res) { },
                  complete: function (res) { },
                })
                console.log("请求数据错误3");
                return
              }
              if (res2.data.status == 200) {


                wx.requestPayment(
                  {
                    'appId': app.globalData.appid,
                    'timeStamp': res2.data.data.timeStamp,
                    'nonceStr': res2.data.data.nonceStr,
                    'package': res2.data.data.package,
                    'signType': 'MD5',
                    'paySign': res2.data.data.paySign,
                    'success': function (res) {

                      wx.showToast({
                        title: '支付成功',
                        icon: 'success',
                        duration: 2000
                      })

                    },
                    'fail': function (res) {

                    },
                    'complete': function (res) {

                      // wx.redirectTo({
                      //   url: '../order_detail/order_detail?orderid=',
                      //   success: function(res) {},
                      //   fail: function(res) {},
                      //   complete: function(res) {},
                      // })


                      wx.navigateBack({
                        delta: 1
                      })


                      console.log(res)
                      // console.log('取消时应该返回购物车')
                      // console.log(res)
                    }
                  })
              }

            }
          })
        }
      })
      return
    }

    if (e.currentTarget.dataset.type){
      wx.request({
        method: 'post',
        url: app.globalData.baseUrl1 + '/order/submitorder/new',
        data: {
          token: app.globalData.token,
          userId: app.globalData.userId,
          prepareId: this.data.prepareId,
          remark: self.data.remark,
          type: e.currentTarget.dataset.type ? 'onAccount' : ''
        },
        header: {
          'content-type': 'application/x-www-form-urlencoded' // 默认值
        },
        success: function (res1) {
          console.log(res1)
          if (res1.data.status != 200) {
              wx.showToast({
                icon:'none',
                title: res1.data.message,
              })
              return
          }
          console.log(1, res1)
          if (e.currentTarget.dataset.type) {
            wx.redirectTo({
              url: '../cancell/cancell?total=' + res1.data.data.totalPrice
            })
            return
          }
        }
      })
      return
    }
    if (this.data.pagetype === 'carts') {
      if (this.data.prepareId === '') {
        // console.log('单号未生成')
        return
      }
      wx.request({
        method: 'post',
        url: app.globalData.baseUrl1 + '/order/submitorder', //仅为示例，并非真实的接口地址
        data: {
          token: app.globalData.token,
          userId: app.globalData.userId,
          prepareId: this.data.prepareId,
          remark: self.data.remark
        },
        header: {
          'content-type': 'application/x-www-form-urlencoded' // 默认值
        },
        success: function (res1) {

          console.log(1, res1)

          wx.request({
            method: 'post',
            url: app.globalData.baseUrl1 + '/wechat/pay/miniapp',
            data: {
              token: app.globalData.token,
              userId: app.globalData.userId,
              openId: app.globalData.openid,
              body: app.globalData.merchant.merchantName,
              outTradeNo: res1.data.data.payId,
              totalFee: res1.data.data.totalPrice
              // self.data.orderPrice * 100
            },
            header: {
              'content-type': 'application/x-www-form-urlencoded' // 默认值
            },
            success: function (res2) {
              console.log('购物车支付', res2)

              if (res2 == null) {

                console.log("网络请求错误3！");
                return;
              }

              if (res2.data.status != 200) {
                wx.showModal({
                  title: '',
                  content: res2.data.data.return_msg,
                  showCancel: false,
                  cancelText: '',
                  cancelColor: '',
                  confirmText: '知道了',
                  confirmColor: '',
                  success: function (res) {



                    wx.navigateBack({
                      delta: 1,
                    })


                   },
                  fail: function (res) { },
                  complete: function (res) { },
                })
                console.log("请求数据错误3");
                return
              }
              if (res2.data.status == 200) {


                wx.requestPayment(
                  {
                    'appId': app.globalData.appid,
                    'timeStamp': res2.data.data.timeStamp,
                    'nonceStr': res2.data.data.nonceStr,
                    'package': res2.data.data.package,
                    'signType': 'MD5',
                    'paySign': res2.data.data.paySign,
                    'success': function (res) {

                      wx.showToast({
                        title: '支付成功',
                        icon: 'success',
                        duration: 2000
                      })

                    },
                    'fail': function (res) {

                    },
                    'complete': function (res) {

                      // wx.redirectTo({
                      //   url: '../order_detail/order_detail?orderid=',
                      //   success: function(res) {},
                      //   fail: function(res) {},
                      //   complete: function(res) {},
                      // })


                      wx.navigateBack({
                        delta: 1
                      })


                      console.log(res)
                      // console.log('取消时应该返回购物车')
                      // console.log(res)
                    }
                  })
              }

            }
          })
        }
      })

    } else {
      let url = app.globalData.baseUrl1 + '/order/submitorder'
      let data = {
        token: app.globalData.token,
        userId: app.globalData.userId,
        prepareId: this.data.prepareId,
        remark: self.data.remark
      }
      let callBack = (res1) => {
        console.log(1, res1)
        if (res1 == null) {

          console.log("网络请求错误2！");
          return;
        }

        if (res1.data.status != 200) {
          console.log("请求数据错误2");
          return;
        }
        if (res1.data.status == 200) {
          let url = app.globalData.baseUrl1 + '/wechat/pay/miniapp'
          let data = {
            token: app.globalData.token,
            userId: app.globalData.userId,
            openId: app.globalData.openid,
            body: app.globalData.merchant.merchantName,
            outTradeNo: res1.data.data.payId,
            totalFee: res1.data.data.totalPrice
            // self.data.orderPrice * 100
          }

          let callBack = (res2) => {
            // console.log(1, res2)
            if (res2 == null) {

              console.log("网络请求错误3！");
              return;
            }

            if (res2.data.status != 200) {
              wx.showModal({
                title: '',
                content: res2.data.data.return_msg,
                showCancel: false,
                cancelText: '',
                cancelColor: '',
                confirmText: '知道了',
                confirmColor: '',
                success: function (res) { 
                  wx.navigateBack({
                    delta: 1,
                  })
                },
                fail: function (res) { },
                complete: function (res) { },
              })
              console.log("请求数据错误3");
              return
            }
            if (res2.data.status == 200) {
              wx.requestPayment(
                {
                  'appId': app.globalData.appid,
                  'timeStamp': res2.data.data.timeStamp,
                  'nonceStr': res2.data.data.nonceStr,
                  'package': res2.data.data.package,
                  'signType': 'MD5',
                  'paySign': res2.data.data.paySign,
                  'success': function (response) {

                    wx.showToast({
                      title: '支付成功',
                      icon: 'success',
                      mask: true,
                      duration: 2000
                    })

                  },
                  'fail': function (res) {

                  },
                  'complete': function (res) {
                    wx.navigateBack({
                      delta: 1
                    })
                  }
                })
            }

          }
          Api.reqFormPost(url, data, callBack)
        }
      }
      Api.reqFormPost(url, data, callBack)



    }
  },


  goPdDatil(e){
    wx.navigateTo({
      url: '../product_datil/product_datil?id=' + e.currentTarget.dataset.goodid,
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  
  // 进来生成预支付订单
  getPreOrder() {
    let self = this

    if (self.data.prepareId === '') {
      return
    }
    console.log('重新进来获取信息' + this.data)
    let url = app.globalData.baseUrl1 + '/order/getprepareorder'
    let data = {
      token: app.globalData.token,
      userId: app.globalData.userId,
      prepareId: self.data.prepareId
    }
    let callBack = (res) => {
       wx.hideLoading() 
      if (res == null) {

        console.log("网络请求错误1！");
        return;
      }

      if (res.data.status != 200) {
        console.log("请求数据错误1");
        return;
      }

      if (res.data.status == 200) {
        console.log(res.data.data)

        let orderNum = 0
        let orderPrice = 0



        if (self.data.pagetype === 'carts') {
          for (let i = 0; i < res.data.data.list.length; i++) {
            for (let j = 0; j < self.data.cartId.split(',').length; j++) {
              if (res.data.data.list[i].id === self.data.cartId.split(',')[j]) {
                orderNum += res.data.data.list[i].num
              }
            }
          }
        } else {
          // orderNum =
        }
        if (res.data.data.address) {
          self.setData({
            defaultAddress: res.data.data.address,
            haveAdd: true
          })
        }

        self.setData({
          productList: res.data.data.list[0].cartlist,
          orderPrice: res.data.data.list[0].totalPrice,
          orderNum: res.data.data.list[0].goodsNum
        })




      }
    }
    Api.reqFormPost(url, data, callBack)


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (app.globalData.merchant === null) {
      return
    } 
    if (app.globalData.merchant.mustLogin || app.globalData.userId === null) {
      if (app.globalData.userId === null) {
        wx.navigateTo({
          url: '/pages/core/login/login',
          success() {
            wx.showToast({
              title: '请先登陆',
              icon: 'loading',
              duration: 1000
            })
          }
        })
        return
      }
    }
    this.setData({
      haveAdd: false,
      paidAccount: app.globalData.merchant.paidAccount
    })
    console.log(app.globalData.merchant)
    console.log('0000000000000')
    this.getPreOrder()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})